package com.lzy.huijinjiazu.mvp.ui.activity;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.support.v7.widget.Toolbar;

import com.flyco.tablayout.SlidingTabLayout;
import com.gyf.barlibrary.ImmersionBar;
import com.jess.arms.base.BaseActivity;
import com.jess.arms.di.component.AppComponent;
import com.jess.arms.widget.autolayout.AutoToolbar;
import com.lzy.huijinjiazu.R;
import com.lzy.huijinjiazu.di.component.DaggerMyOrderComponent;
import com.lzy.huijinjiazu.di.module.MyOrderModule;
import com.lzy.huijinjiazu.mvp.contract.MyOrderContract;
import com.lzy.huijinjiazu.mvp.presenter.MyOrderPresenter;
import com.lzy.huijinjiazu.mvp.ui.adapter.TabsAdapter;

import butterknife.BindView;
import butterknife.ButterKnife;


public class MyOrderActivity extends BaseActivity<MyOrderPresenter> implements MyOrderContract.View {

    @BindView(R.id.tabLayout)
    SlidingTabLayout mTabLayout;
    @BindView(R.id.viewPager)
    ViewPager mViewPager;
    @BindView(R.id.toolbar)
    Toolbar mToolbar;

    @Override
    public void setupActivityComponent(AppComponent appComponent) {
        DaggerMyOrderComponent //如找不到该类,请编译一下项目
                .builder()
                .appComponent(appComponent)
                .myOrderModule(new MyOrderModule(this))
                .build()
                .inject(this);
    }

    @Override
    public int initView(Bundle savedInstanceState) {
        return R.layout.activity_my_order; //如果你不需要框架帮你设置 setContentView(id) 需要自行设置,请返回 0
    }

    @Override
    public void initData(Bundle savedInstanceState) {
        mPresenter.initTabLayout();
    }

    @Override
    protected void initImmersionBar() {
        super.initImmersionBar();
        mImmersionBar.setTitleBarMarginTop(this, mToolbar);
    }

    @Override
    public void showTabLayout(String[] title, Fragment[] tabFragment) {
        mViewPager.setAdapter(new TabsAdapter(getSupportFragmentManager(), tabFragment, title));
        mTabLayout.setViewPager(mViewPager);
        mTabLayout.setCurrentTab(0);
    }

}
